package com.imooc.miaoshaproject.service;

import com.imooc.miaoshaproject.exceptions.ServiceException;
import com.imooc.miaoshaproject.service.model.ItemModel;

import java.util.List;

/**
 * 商品服务
 *
 * @author chenjianfei
 */
public interface ItemService {

    /**
     * 创建商品
     *
     * @param itemModel
     * @return
     * @throws ServiceException
     */
    ItemModel createItem(ItemModel itemModel) throws ServiceException;

    /**
     * 商品列表浏览
     *
     * @return
     */
    List<ItemModel> listItem();

    /**
     * 商品详情浏览
     *
     * @param id
     * @return
     */
    ItemModel getItemById(Integer id);

    /**
     * 库存扣减
     *
     * @param itemId
     * @param amount
     * @return
     * @throws ServiceException
     */
    boolean decreaseStock(Integer itemId, Integer amount) throws ServiceException;

    /**
     * 商品销量增加
     *
     * @param itemId
     * @param amount
     * @throws ServiceException
     */
    void increaseSales(Integer itemId, Integer amount) throws ServiceException;

}
